#include <stdio.h>
int main()
{
    int a[10001],i,n,t;
    a[1]=2;
    for (i=2;i<10001;i++)a[i]=a[i-1]+6*(i-1);
    scanf("%d",&n);
    while (n--)
    {
        scanf("%d",&t);
        printf("%d\n",a[t]);
    }
    return 0;
}
